using UnityEngine;
using UnityEngine.UI;

namespace AudioStudio
{
    public class AudioState : StateMachineBehaviour
    {
        public AudioEvent audioEvent;

        override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo,int layerIndex)
        {
            AnimationSound s = animator.gameObject.GetComponent<AnimationSound>();
            if(s != null)
            {
                s.PlaySound(audioEvent.Name);
            }
        }

		override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo,int layerIndex)
        {
            AnimationSound s = animator.gameObject.GetComponent<AnimationSound>();
            if(s != null)
            {
                s.StopSound(audioEvent.Name);
            }
        }
    }
}
